<template>
	<view class="content">
		<view class="m-b-10">
			<u-notice-bar :text="noticeInfo" direction="column"></u-notice-bar>
		</view>
		<template v-for="(item, index) in appCategoryList" :index="index">
			<applicationItem v-bind="item" :appList="item.appList" />
		</template>
	</view>
	<u-overlay :show="mainStore.showTip" @click="closemask"></u-overlay>
</template>
<script setup>
import { onShow } from '@dcloudio/uni-app';
import { computed, ref } from 'vue';
import { getAuthorization } from '@/router/auth.js';
import { useMainStore } from '@/store/index.js';
import { getNoticeData } from '@/api/hidden-danger.js';
import { setMessageBadge } from '@/hooks/com.js';
const mainStore = useMainStore();
import applicationItem from './application-item.vue';
let noticeInfo = ref(['1', '2']);
const appCategoryList = computed(() => {
	mainStore.fastList.forEach((item) => {
		item.tip = false;
	});
	return [
		{
			title: '工作台模块',
			appList: [
				{
					name: '双重预防',
					path: '/pages/professional/main/index',
					icon: 'syf'
				}
				// {
				// 	name: '四员两长',
				// 	path: '/pages/professional/examine/index',
				// 	icon: 'sylc',
				// 	suffix: 'png'
				// },
				// {
				// 	name: '高危作业',
				// 	path: '/pages/professional/riskOperations/index',
				// 	icon: 'gw',
				// }
			]
		},
		{
			title: '快捷入口',
			appList: mainStore.fastList
		}
	];
});
const closemask = () => {
	if (!mainStore.overlay) {
		mainStore.showTip = false;
	}
	mainStore.overlay = false;
};
const getNotice = async () => {
	try {
		const { data = [] } = await getNoticeData();
		noticeInfo.value = data.map((item, index) => `${index + 1}.上报日期:${item.checkDate} 风险点:${item.riskLocationName} `);
	} catch (e) {
		//TODO handle the exception
	}
};
onShow(() => {
	if (getAuthorization('accessToken')) {
		getNotice();
		setMessageBadge();
	}
});
</script>
<style lang="scss" scoped>
.content {
	padding: 20rpx 20rpx 40rpx 20rpx;
}

.mask {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 999;
	width: 100%;
	height: 100%;
	pointer-events: auto;
	background: rgba(0, 0, 0, 0.4);
	transition-property: opacity;
	transition-duration: 300ms;
	transition-timing-function: ease-out;
}

.mask {
}
</style>